/*
 * Copyright (c) 1997 - 2012 Rakuten, Inc. All Rights Reserved.
 * $Id$
 * Created on 2012/05/29
 */
package com.rakuten.api.mule.model.item;

import java.io.Serializable;
import java.util.Date;

import org.codehaus.jackson.annotate.JsonPropertyOrder;

/**
 * 
 * @author hayatsu
 */
@JsonPropertyOrder({ "liveStartTime", "liveEndTime" })
public class ItemDuration implements Serializable {

	private static final long serialVersionUID = 1L;
	private java.util.Date liveStartTime;
	private java.util.Date liveEndTime;

	public ItemDuration() {
	}

	public ItemDuration(Date liveStartTime, Date liveEndTime) {
		this.liveStartTime = liveStartTime;
		this.liveEndTime = liveEndTime;
	}

	public Date getLiveStartTime() {
		return liveStartTime;
	}

	public void setLiveStartTime(Date liveStartTime) {
		this.liveStartTime = liveStartTime;
	}

	public Date getLiveEndTime() {
		return liveEndTime;
	}

	public void setLiveEndTime(Date liveEndTime) {
		this.liveEndTime = liveEndTime;
	}

	public boolean isLive(long currentTimeMillis) {
		// assume null values means infinity(negative for startTime, positive
		// for endTime)
		if (liveStartTime != null
				&& liveStartTime.getTime() > currentTimeMillis)
			return false;
		if (liveEndTime != null && liveEndTime.getTime() < currentTimeMillis)
			return false;
		return true;
	}
}
